﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model;

namespace BLL
{
   public partial class goodsflowingManager
    {
        //根据条件获取商品流水
       public IQueryable<goodsflowing> GetByTime(string start, string end, string opertor, string opType)
        {
            ZG_OAEntities ds = new ZG_OAEntities();
            var query = from obj in ds.goodsflowing orderby obj.id descending select obj;
            if (!string.IsNullOrEmpty(start) && start != "null")
            {
                DateTime dt = Convert.ToDateTime(start);
                query = from obj in query where obj.Time >= dt orderby obj.id descending select obj;
            }
            if (!string.IsNullOrEmpty(end) && end != "null")
            {
                DateTime dt2 = Convert.ToDateTime(end);
                query = from obj in query where obj.Time <= dt2 orderby obj.id descending select obj;
            }
            if (!string.IsNullOrEmpty(opertor) && opertor != "null")
            {
                if (opertor != "所有操作员")
                {
                    query = from obj in query where obj.username == opertor orderby obj.id descending select obj;
                }
            }
            if (!string.IsNullOrEmpty(opType) && opType != "null")
            {
                if (opType != "所有类型")
                {
                    query = from obj in query where obj.operate==opType orderby obj.id descending select obj;
                }
               
            }
            return query;
        }
    }
}
